<?php
define('APPID','wx13ccb587651b27b4');
define('APPSECRET','d4624c36b6795d1d99dcf0547af5443d');
public function getaccesstoken()
{
	if(!isset($access_token) || time() - $creattokentime > $expires_in)
	{
		$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".APPID."&secret=".APPSECRET;
		$ch = curl_init();
		curl_setopt( $ch , CURLOPT_URL , $url);
		curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , FALSE );
		curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST , FALSE );
		curl_setopt( $ch , CURLOPT_RETURNTRANSFER , TRUE );
		$content = curl_exec($ch);
		$jsoninfo = json_decode($content,true);
		$access_token = $jsoninfo["access_token"];
		$expires_in = $jsoninfo["expires_in"];
		$creattokentime = time();
		return $access_token;
	}
	else
	{
		return $access_token;
	}
}
?>